﻿public class DAL
{
    private static DAL instance;
    private VariablesWall variablesWall;
    private VariablesObstacle variablesObstacle;

    public static DAL Instance 
    { 
        get
        {
            if (instance == null)
                instance = new DAL();

            return instance;
        }         
    }

    private DAL()
    {
        variablesWall = getVariablesWall();
        variablesObstacle = getVariablesObstacle();
    }

    private VariablesWall getVariablesWall()
    {
        return GameObjectManager.findObjectByType<VariablesWall>(typeof(VariablesWall));
    }

    private VariablesObstacle getVariablesObstacle()
    {
        return GameObjectManager.findObjectByType<VariablesObstacle>(typeof(VariablesObstacle));
    }

    public WallModel createWallModel()
    {
        WallModel result = new WallModel();
        
        result.SpeedIncrement = variablesWall.SPEED_INCREMENT;
        result.SpeedInitial = variablesWall.SPEED_INITIAL;
        result.SpeedMax = variablesWall.SPEED_MAX;
        result.SpeedTimeInterval = variablesWall.SPEED_TIME_INTERVAL;
        result.MaxHeight = variablesWall.MAX_HEIGHT;
        result.MinHeight = variablesWall.MIN_HEIGHT;
        result.StepY = variablesWall.STEP_Y;
        result.CountBlocks = variablesWall.COUNT_BLOCKS;
        result.FinalX = variablesWall.FINAL_X;

        return result;
    }

    public ObstacleModel createObstacleModel()
    {
        ObstacleModel result = new ObstacleModel();

        result.SpeedIncrement = variablesObstacle.SPEED_INCREMENT;
        result.SpeedInitial = variablesObstacle.SPEED_INITIAL;
        result.SpeedMax = variablesObstacle.SPEED_MAX;
        result.SpeedTimeInterval = variablesObstacle.SPEED_TIME_INTERVAL;
        result.FinalX = variablesObstacle.FINAL_X;
        result.MinY = variablesObstacle.MIN_Y;
        result.MinY = variablesObstacle.MAX_Y;
        result.Gap = variablesObstacle.GAP;
        result.SizeScreen = variablesObstacle.SIZE_SCREEN;

        return result;
    }
}